<template>
	<view>
		<view class="deposit-msg">
			<view class="add-address-details" v-if="type == 2">
				<view class="add-address-title" style="letter-spacing: 18upx;">收款人</view>
				<view class="add-address-textarea" style="margin-left: 24upx;">
					<input type="text"   v-model="info.account_name" placeholder="请先到店铺信息绑卡" disabled/>
				</view>
			</view>
			<view class="add-address-details" v-if="type == 2">
				<view class="add-address-title">开户银行</view>
				<view class="add-address-textarea">
					<input type="text" v-if="info.bank_id" v-model="info.bank_id.bankname" placeholder="请先到店铺信息绑卡" disabled />
					<input type="text" v-else placeholder="请先到店铺信息绑卡" disabled />
				</view>
			</view>
			<view class="add-address-details" v-if="type == 2">
				<view class="add-address-title">银行卡号</view>
				<view class="add-address-textarea">
					<input type="text"  v-model="info.account_number" placeholder="请先到店铺信息绑卡" disabled />
				</view>
			</view>
			<view class="add-address-details" v-if="type == 1">
				<view class="add-address-title">认证名字</view>
				<view class="add-address-textarea">
					<input type="text"  v-model="name" value="" placeholder="请输入你的真实姓名"/>
				</view>
			</view>
			<view class="add-address-details" v-if="type == 1">
				<view class="add-address-title">手机号码</view>
				<view class="add-address-textarea">
					<input type="text"  v-model="phone" value="" placeholder="请输入微信绑定手机号码"/>
				</view>
			</view>
			<view class="add-address-details" style="border: none;">
				<view class="add-address-title">提现金额</view>
				<view class="add-address-textarea">
					<input type="text"  v-model="amount" value="" placeholder="请输入你的提现金额"/>
				</view>
			</view>
			<view class="deposit-btn"  @click="depositClick">
				提现
			</view>
		</view>
		<view class="deposit-explain">
			<view class="explain-title">
				<view class=""></view>
				<view class="">
					提现说明
				</view>
			</view>
			<view class="deposit-explain-content">
				<view class="" v-if="type == 2">
					1.单笔提现金额最低1元，提现一般1-3个工作日到账，请留意短信通知。如提现3天还没有到账，请联系“ 客服人员”。
				</view>
				<view class="" v-if="type == 1">
					1.单笔提现金额最低1元，提现一般1-3个工作日到账，请留意微信通知。如提现3天还没有到账，请联系“ 客服人员”。
				</view>
				<view class="">
					2.如果出现提现失败，请第一时间联系“客服人员”。
				</view>
			</view>
		</view>
		<!-- 申请提现成功弹框 -->
		<uni-popup ref="depositSucced" :custom="true">
			<view class="popup_box_de">
				<view class="popup_box-tip">
					申请提现成功
				</view>
				<view class="popup_box-reminder">
				1-3个工作日到账
				</view>
				<view class="popup_box-click" @click="close">
					确定
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import uniPopup from '@/components/uni-popup/uni-popup.vue'
	export default{
		components:{uniPopup},
		data(){
			return {
				store_id:"",
				info:[],
				amount:0,
				name:'',
				payment:0,
				phone:'',
				type:'',
				is_online:0,
				is_online_courses:0,
				level:0
			}
		},
		onLoad(options) {
			let store_id = parseInt(options.store_id,10);
			console.log('进入了onload 获取url的store_id',store_id)
			if(!store_id > 0){
				store_id = uni.getStorageSync('store_id')?parseInt(uni.getStorageSync('store_id'),10):0
			}else{
				uni.setStorageSync('store_id', store_id)
			}
			if(options.is_online){
				this.is_online=parseInt(options.is_online,10)
			}
			if(options.is_online_courses){
				this.is_online_courses=parseInt(options.is_online_courses,10)
			}
			this.type = parseInt(options.type,10)
			console.log(this.type,"*********************************");
			this.store_id = parseInt(store_id,10)
			this.level=options.level
			this.$store.commit('updateStoreId',store_id)
			this.get_bank_info()
			this.getShopMsg()
		},
		methods:{
			depositClick(){
				const that = this;
				// console.log(data,"12345")
				if(this.is_online){
					const data = {
						token:that.$store.getters.token,
						amount:that.amount,
						username:that.name,
						phone:that.phone,
						type:that.type,
						customer_id:parseInt(uni.getStorageSync('customer_id'),10),
						check_name:that.name,
						money:that.amount,
						level:this.level,
						type:this.is_online_courses==1?'online_courses':'new_user'
					}
					this.$api.submit_apply(data).then(res => {
						console.log(res,"submit_apply");
						if(res.status){
							this.$refs.depositSucced.open()
						}else{
							uni.showToast({
								title:res.msg,
								icon:"none",
								duration:2000
							})
						}
						
					}).catch(err => {
						console.log(err,'that.$api.withdraw')
					})
				}else{
					const data = {
						token:that.$store.getters.token,
						amount:that.amount,
						username:that.name,
						phone:that.phone,
						type:that.type,
						customer_id:parseInt(uni.getStorageSync('customer_id'),10),
						check_name:that.name,
						money:that.amount,
						// type:'new_user'
					}
					that.$api.withdraw(data).then(res => {
						console.log(res,"+++++++++++++++++++++++++++++++");
						if(res.status){
							this.$refs.depositSucced.open()
						}else{
							uni.showToast({
								title:res.msg,
								icon:"none",
								duration:2000
							})
						}
						
					}).catch(err => {
						console.log(err,'that.$api.withdraw')
					})
				}
			},
			close(){
				this.$refs.depositSucced.close()
			},
			// 获取店铺信息
			getShopMsg(){
				console.log(this.store_id,'store_id')
				let data = {
					token:this.$store.getters.getToken,
					customer_store_id:this.store_id,
				}
				this.$api.gain_shop_msg(data).then(res =>{
					 if(res.status){
						 this.payment = res.data.payment_type
						 console.log('提现方式',this.payment)
					 }
				}).catch(err => {
					console.log(err)
				})
			},
			// 获取银行卡信息
			get_bank_info(){
				let data={
					token:this.$store.state.token,
					store_id:this.store_id
				}
				this.$api.is_binding_card(data).then(re=>{
					let customer_store_identification_id=re.res
					let data2={
						customer_store_identification_id:customer_store_identification_id
					}
					this.$api.gain_bingind_msg(data2).then(res=>{
						console.log(res)
						this.info=res.list
					})
				})
			},
			
		}
	}
</script>

<style>
	/* 弹框样式 */
	.popup_box_de{
		height: 336upx;
		width: 640upx;
		background: #FFFFFF;
		border-radius: 24upx;
		padding-top: 50upx;
		box-sizing: border-box;
	}
	.popup_box-tip{
		text-align: center;
		color: #353535;
		font-size: 36upx;
		font-weight: 800;
	}
	.popup_box-reminder{
		width: 544upx;
		text-align: center;
		padding: 0 10upx;
		box-sizing: border-box;
		color: #FF5C46;
		font-size: 30upx;
		margin: 0 auto;
		margin-top: 36upx;
	}
	.popup_box-click{
		width: 100%;
		height: 110upx;
		margin-top: 66upx;
		border-top: 1upx solid rgba(0, 0, 0, 0.1);
		color: #FF8B46;
		font-size: 34upx;
		text-align: center;
		line-height: 110upx;
	}
	page{
		background: #F3F3F4;
	}
	.deposit-msg{
		width: 100%;
		padding-left: 30upx;
		padding-bottom: 30upx;
		box-sizing: border-box;
		background: #FFFFFF;
	}
	.add-address-details{
		width: 100%;
		height: 100upx;
		padding: 32upx 30upx 28upx 0;
		box-sizing: border-box;
		display: flex;
		border-bottom: 1upx solid #DEDEDE;
	}
	.add-address-title{
		font-size: 28upx;
		color: #666666;
	}
	.add-address-textarea{
		position: relative;
		flex-grow: 1;
		margin-left: 40upx;
	}
	.add-address-details>view>input{
		font-size: 28upx;
		flex-grow: 1;
	}
	.deposit-btn{
		width: 638upx;
		height: 88upx;
		line-height: 88upx;
		text-align: center;
		color: #FFFFFF;
		font-size: 32upx;
		margin: 0 auto;
		margin-top: 50upx;
		border-radius: 44upx;
		background: linear-gradient(to right,#FE9543,#FF664F);
		box-shadow: 0 8upx 16upx 0 rgba(166, 13, 0, 0.23);
	}
	.deposit-explain{
		width: 100%;
		margin-top: 20upx;
		background: #FFFFFF;
		padding: 0 30upx;
		padding-bottom: 30upx;
		box-sizing: border-box;
	}
	.explain-title{
		display: flex;
		padding: 30upx 0 22upx;
		box-sizing: border-box;
		border-bottom: 1upx solid #DEDEDE;
	}
	.explain-title>view:first-child{
		width: 8upx;
		height: 32upx;
		background: #FF8B46;
		vertical-align: middle;
		margin-top: 6upx;
	}
	.explain-title>view:last-child{
		color: #333333;
		font-size: 34upx;
		margin-left: 10upx;
	}
	.deposit-explain-content>view{
		margin-top: 30upx;
		color: #666666;
		font-size: 28upx;
	}
</style>
